package co.th.helper.jdbc.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import co.th.helper.jdbc.RowMapper;
import co.th.helper.model.Region;

public class RegionRowMapper extends RowMapper<Region> {

	@Override
	public Region mapRow(ResultSet resultSet) throws SQLException {
		Region region = new Region();

		if (isThere(resultSet, "region_id")) {
			region.setRegionId(resultSet.getBigDecimal("region_id"));
		}

		if (isThere(resultSet, "region_name_th")) {
			region.setRegionNameTH(resultSet.getString("region_name_th"));
		}

		if (isThere(resultSet, "region_name_en")) {
			region.setRegionNameEN(resultSet.getString("region_name_en"));
		}

		if (isThere(resultSet, "create_by")) {
			region.setCreateBy(resultSet.getString("create_by"));
		}

		if (isThere(resultSet, "create_date")) {
			region.setCreateDate(resultSet.getDate("create_date"));
		}

		if (isThere(resultSet, "update_by")) {
			region.setUpdateBy(resultSet.getString("update_by"));
		}

		if (isThere(resultSet, "update_date")) {
			region.setUpdateDate(resultSet.getDate("update_date"));
		}

		return region;
	}

}
